////#import <UIKit/UIKit.h>
////
////@class RatingInfoView;
////
////@protocol RatingInfoViewDelegate <NSObject>
////
////@optional
/////**
//// * 选中分类变化回调
//// * @param view 视图
//// * @param index 选中索引
//// */
////- (void)ratingInfoView:(RatingInfoView *)view didSelectCategoryAtIndex:(NSInteger)index;
////
////@end
////
////@interface RatingInfoView : UIView
////
////@property (nonatomic, assign) CGFloat goodRate;           // 好评率
////@property (nonatomic, assign) NSInteger allCount;         // 全部评价数量
////@property (nonatomic, assign) NSInteger goodCount;        // 好评数量
////@property (nonatomic, assign) NSInteger mediumCount;      // 中评数量
////@property (nonatomic, assign) NSInteger badCount;         // 差评数量
////@property (nonatomic, assign) NSInteger picCount;         // 有图评价数量
////
////@property (nonatomic, strong) UIColor *containerBackgroundColor;  // 容器背景色
////@property (nonatomic, strong) UIColor *goodRateTextColor;         // 好评率文字颜色
////@property (nonatomic, strong) UIColor *categoryTextColor;         // 分类文字颜色
////
////@property (nonatomic, assign) NSInteger selectedIndex;    // 当前选中索引
////
////@property (nonatomic, strong) UIColor *normalTextColor;           // 普通文字颜色
////@property (nonatomic, strong) UIColor *selectedTextColor;         // 选中文字颜色
////
////@property (nonatomic, weak) id<RatingInfoViewDelegate> delegate;  // 代理
////
/////**
//// * 初始化方法
//// * @param frame 视图框架
//// * @param categoryTitles 分类标题数组
//// */
////- (instancetype)initWithFrame:(CGRect)frame categoryTitles:(NSArray<NSString *> *)categoryTitles;
////
/////**
//// * 更新视图数据
//// */
////- (void)updateViewData;
////
/////**
//// * 计算视图高度
//// * @param width 视图宽度
//// * @return 计算的高度
//// */
////+ (CGFloat)calculateHeightForWidth:(CGFloat)width;
////
/////**
//// * 设置选中的分类
//// * @param index 分类索引
//// * @param animated 是否动画
//// */
////- (void)setSelectedIndex:(NSInteger)index animated:(BOOL)animated;
////
////
////@end    
//
//
//#import <UIKit/UIKit.h>
//
//@protocol RatingInfoViewDelegate;
//
//@interface RatingInfoView : UIView
//
//@property (nonatomic, assign) CGFloat goodRate;           // 好评率
//@property (nonatomic, assign) NSInteger allCount;         // 全部评价数量
//@property (nonatomic, assign) NSInteger goodCount;        // 好评数量
//@property (nonatomic, assign) NSInteger mediumCount;      // 中评数量
//@property (nonatomic, assign) NSInteger badCount;         // 差评数量
//@property (nonatomic, assign) NSInteger picCount;         // 有图评价数量
//@property (nonatomic, assign) NSInteger selectedIndex;    // 当前选中索引
//@property (nonatomic, assign) NSInteger maxItemsPerRow;   // 每行最大项目数
//
//@property (nonatomic, strong) UIColor *containerBackgroundColor;  // 容器背景色
//@property (nonatomic, strong) UIColor *goodRateTextColor;         // 好评率文字颜色
//@property (nonatomic, strong) UIColor *normalTextColor;           // 普通文字颜色
//@property (nonatomic, strong) UIColor *selectedTextColor;         // 选中文字颜色
//
//@property (nonatomic, weak) id<RatingInfoViewDelegate> delegate;  // 代理
//
///**
// * 初始化方法
// * @param frame 视图框架
// * @param categoryTitles 分类标题数组
// */
//- (instancetype)initWithFrame:(CGRect)frame categoryTitles:(NSArray<NSString *> *)categoryTitles;
//+ (CGFloat)calculateHeightForWidth:(CGFloat)width;
//
///**
// * 更新视图数据
// */
//- (void)updateViewData;
//
///**
// * 计算视图高度
// * @param width 视图宽度
// * @return 计算的高度
// */
//+ (CGFloat)calculateHeightForWidth:(CGFloat)width categoryCount:(NSInteger)count maxItemsPerRow:(NSInteger)maxItems;
//
///**
// * 设置选中的分类
// * @param index 分类索引
// * @param animated 是否动画
// */
//- (void)setSelectedIndex:(NSInteger)index animated:(BOOL)animated;
//
//@end
//
//@protocol RatingInfoViewDelegate <NSObject>
//
//@optional
///**
// * 选中分类变化回调
// * @param view 视图
// * @param index 选中索引
// */
//- (void)ratingInfoView:(RatingInfoView *)view didSelectCategoryAtIndex:(NSInteger)index;
//
//@end    



// 定义全局常量
static NSString *const CellIdentifier = @"Cell";
static NSInteger const ColumnCount = 3; // 列数（九宫格为3列）
static CGFloat const ItemSpacing = 10; // 元素间距
static CGFloat const EdgeInsets = 15; // 边距

#import <UIKit/UIKit.h>
@class RatingInfoView;
@protocol RatingInfoViewDelegate;

@interface RatingInfoView : UIView<UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource>

@property (nonatomic, strong) UIColor *backgroundColor;        // 背景色
@property (nonatomic, strong) UIColor *titleTextColor;         // 标题文字颜色
@property (nonatomic, strong) UIColor *ratingTextColor;        // 评分文字颜色
@property (nonatomic, strong) UIColor *selectedTextColor;      // 选中文字颜色
@property (nonatomic, strong) UIColor *borderColor;            // 边框颜色
@property (nonatomic, assign) CGFloat borderWidth;             // 边框宽度
@property (nonatomic, assign) CGFloat cornerRadius;            // 圆角半径
@property (nonatomic, assign) CGFloat itemSpacing;             // 项目间距
@property (nonatomic, assign) NSInteger selectedIndex;         // 当前选中索引
@property (nonatomic, assign) CGFloat overallRating;           // 总体评分
@property (nonatomic, copy) NSString *overallTitle;            // 总体标题

@property (nonatomic, assign) id<RatingInfoViewDelegate>delegate;            // 总体标题
@property (nonatomic, strong) NSDictionary *reviewData; // 评价数据

@property (nonatomic, strong) NSArray *dataArray; // 数据源（示例为图片名称数组）


/**
 * 初始化方法
 * @param frame 视图框架
 * @param ratingTypes 评价类型数组
 */
- (instancetype)initWithFrame:(CGRect)frame ratingTypes:(NSArray<NSString *> *)ratingTypes;

/**
 * 设置评价数据
 * @param counts 各类型评价数量数组
 */
- (void)setRatingCounts:(NSArray<NSNumber *> *)counts;

/**
 * 设置选中的评价类型
 * @param index 类型索引
 * @param animated 是否动画
 */
- (void)setSelectedIndex:(NSInteger)index animated:(BOOL)animated;

- (void)updateWithData:(NSDictionary *)data;

@end

@protocol RatingInfoViewDelegate <NSObject>

@optional
/**
 * 选中评价类型变化回调
 * @param grid 评价网格
 * @param index 选中索引
 */
- (void)ratingGrid:(RatingInfoView *)grid didSelectTypeAtIndex:(NSInteger)index;

- (void)orderReviewsView:(id)view didSelectReviewType:(NSString *)reviewType;





- (instancetype)initWithFrame:(CGRect)frame;

@end
